home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 27 / 027.d81 / t.bitmap i_o 128 < prev    next >
Text File  |  2022-08-26  |  4KB  |  216 lines

  1.  
  2.  
  3. SAVING AND LOADING THE COMMODORE 128
  4.            GRAPHIC BIT MAP
  5.                  by
  6.          Morton A. Kevelson
  7.  
  8.  
  9. COMMODORE MICROCOMPUTERS MAGAZINE
  10. July/August, 1986
  11.  
  12.  
  13. **************************************
  14. NOTE: Because this program is written
  15. for the Commodore 128, it cannot be
  16. run like other programs in LOADSTAR.
  17. To run this program, press your RESET
  18. button.  This will automatically
  19. display a menu of all C-128 programs
  20. in this issue.  Choose the program you
  21. wish to run from this menu.
  22. **************************************
  23.  
  24.  
  25.   The C-128's BASIC 7.0 has built-in
  26.  
  27. commands that allow you to create
  28.  
  29. both high-res and multicolor graphics.
  30.  
  31. But because each step in drawing must
  32.  
  33. be specified by a BASIC command,
  34.  
  35. drawing a complex image will take up
  36.  
  37. a great deal of time as well as a
  38.  
  39. great deal of program space.
  40.  
  41.  
  42.   The solution to this problem is to
  43.  
  44. save your graphic image to disk as a
  45.  
  46. binary program file.  This way, only a
  47.  
  48. few BASIC commands are required to
  49.  
  50. redisplay the image, reducing program
  51.  
  52. overhead.  (All that is required in
  53.  
  54. the program is the image file name,
  55.  
  56. and even it may also be saved to
  57.  
  58. disk).
  59.  
  60.  
  61.   In addition to saving space, this
  62.  
  63. solution also saves time-- if you
  64.  
  65. have a 1571 disk drive, it takes only
  66.  
  67. about four seconds to load a high-res
  68.  
  69. graphic, only six seconds to load a
  70.  
  71. multicolor graphic.
  72.  
  73.  
  74.   Also, working directly with the
  75.  
  76. Commodore 128's graphic bit map lets
  77.  
  78. you import images from existing
  79.  
  80. Commodore graphics packages.  Once
  81.  
  82. you know the format of these images,
  83.  
  84. you can easily convert them into
  85.  
  86. usable form with the BSAVE or BLOAD
  87.  
  88. commands, or with the 128's built-in
  89.  
  90. machine language monitor.
  91.  
  92.  
  93. BAD NEWS/GOOD NEWS.....
  94.  
  95.  
  96.   While saving and loading a high-res
  97.  
  98. bit map is relatively straightforward,
  99.  
  100. doing the same to a multicolor
  101.  
  102. bit-mapped image is another story.
  103.  
  104. Fortunately, Morton Kevelson's two
  105.  
  106. programs perform all of the activities
  107.  
  108. required to save and load both kinds
  109.  
  110. of images.  These programs can be
  111.  
  112. added to your own programs as
  113.  
  114. subroutines.
  115.  
  116.  
  117.   The save routine expects the image
  118.  
  119. to be in either the appropriate
  120.  
  121. graphic mode or split-screen mode when
  122.  
  123. it's called; exiting the subroutine
  124.  
  125. restores this mode.  If you attempt to
  126.  
  127. enter while in text display, you will
  128.  
  129. simply return to the calling program.
  130.  
  131.  
  132.   The save routine will check the
  133.  
  134. current graphic mode and prompt you
  135.  
  136. to enter an image file name for the
  137.  
  138. bit map.  For a high-res image, the
  139.  
  140. bit map and screen memory are saved
  141.  
  142. as a single file.  A saved multicolor
  143.  
  144. image uses the same block of memory
  145.  
  146. plus a separate file containing color
  147.  
  148. memory from $D800.  (A color memory
  149.  
  150. file will have a ".CM" suffix-- even
  151.  
  152. if the file name must be truncated to
  153.  
  154. thirteen characters).
  155.  
  156.  
  157.   Kevelson's programs make use of
  158.  
  159. some of the extra bytes between the
  160.  
  161. screen memory and the bit map.  He
  162.  
  163. stores the screen border color in
  164.  
  165. 8169, the graphic display mode in
  166.  
  167. 8170.
  168.  
  169.  
  170.   The loader subroutine first assumes
  171.  
  172. that you are working with a high-res
  173.  
  174. picture.  After the screen memory and
  175.  
  176. bit map are loaded, the loader
  177.  
  178. subroutine checks location 8170 and
  179.  
  180. switches modes if necessary.  Color
  181.  
  182. memory is then loaded.  Note that the
  183.  
  184. background and border color values
  185.  
  186. are the VIC chip values, which are
  187.  
  188. incremented by one for use with BASIC.
  189.  
  190.  
  191.   NOTE: if you are converting
  192.  
  193. Commodore bit maps to this format,
  194.  
  195. you will find that not all graphic
  196.  
  197. packages save the background and
  198.  
  199. border colors-- some assume the
  200.  
  201. background to be white or black.  If
  202.  
  203. you come across files of this type,
  204.  
  205. you must modify the saved files or
  206.  
  207. the load routine.
  208.  
  209.  
  210. FILES REQUIRED:
  211.  
  212. BITMAP LOAD 128
  213. BITMAP SAVE 128
  214.  
  215. -----------< end of text >------------
  216.